/**
 * @copyright   2010-2017, The Titon Project
 * @license     http://opensource.org/licenses/BSD-3-Clause
 * @link        http://titon.io
 */

$titon-internal-modules-exported: () !global;

/**
 * Compile a component into the final output only once.
 * Also check to see if it has been excluded from the output all together.
 *
 * @param string $module
 */
@mixin export($module) {

    // Module is excluded, so do nothing
    @if (map-get($titon-settings-flags, "all-modules") == false and index(setting("exclude-modules"), $module) != null) {

    // Module hasn't been exported yet, so export it and log usage
    } @else if (index($titon-internal-modules-exported, $module) == null) {
        $titon-internal-modules-exported: append($titon-internal-modules-exported, $module) !global;

        @content;
    }
}

/**
 * Clear all floats within the container.
 */
@mixin clear-fix {
    &::after {
        content: "";
        display: table;
        clear: both;
    }
}

/**
 * Render small font sizes and padding.
 */
@mixin size-small {
    font-size: theme-setting("small-font-size");
    padding: theme-setting("small-padding");
}

/**
 * Render medium font sizes and padding (default size).
 */
@mixin size-medium {
    font-size: theme-setting("medium-font-size");
    padding: theme-setting("medium-padding");
}

/**
 * Render large font sizes and padding.
 */
@mixin size-large {
    font-size: theme-setting("large-font-size");
    padding: theme-setting("large-padding");
}

/**
 * Include content for the small modifier size if enabled in the feature flags.
 *
 * @param string $component
 */
@mixin generate-size-small($component: "") {
    @if is-feature-enabled("small-size") {
        #{bem($component, "", "small")} {
            @content;
        }
    }
}

/**
 * Include content for the large modifier size if enabled in the feature flags.
 */
@mixin generate-size-large($component: "") {
    @if is-feature-enabled("large-size") {
        #{bem($component, "", "large")} {
            @content;
        }
    }
}

/**
 * Include content for LTR elements.
 */
@mixin ltr() {
    &[dir="ltr"] {
        @content;
    }
}

/**
 * Include content for RTL elements.
 */
@mixin rtl() {
    &[dir="rtl"] {
        @content;
    }
}
